// pages/spxiangq/spxiangq.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    details: '', //详情数据
    SALES_TYPE: '', //判断是否购买
    GOODS_CLASSIFICATION: '', //判断是否是虚拟商品
    CUSTOMER_TEL: '', //客户手机号
    GOODS_ID: '', //商品单号
    ADDRESS_ID: '', //返回的地址ID
    openid: '',
    PAYMENT_AMOUNT: '',
    MESSAGE: '',
    ORDER_NUMBER: '',
    ORDER_PRICE_ZERO: '',
    prepay_id: '',
    nonceStr: '',
    package: '',
    paySign: '',
    signType: '',
    timeStamp: '',



    business: '', //网点
    shi_k: true,
    qu_k: true,
    wang_k: true,

    lijigoumai:true,
    chakanxingxi:true,

    chuashuju:'',

  },

  back() {
    wx.navigateBack({
      delta: 1
    })
  },

  purchase() {
    wx.navigateTo({
      url: '../../pages/youpiaozhifu/youpiaozhifu?data=' + JSON.stringify(this.data.details)
    })

  },
  shuju() {
    this.setData({
      openid: app.globalData.openid
    });
    wx.request({
      url: app.globalData.interface+'/post/API_1111_getGoodsPost',
      method: 'get',
      data: {

        GOODS_ID: 2000036370
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: res => {
        console.log(res.data.data);


        if (res.data.result == 'success') {
          this.setData({
            details: res.data.data
          })
        }
      }
    })
  },

 



  // 查看是否购买
  chakangoumai() {
    console.log(this.data.openid);
    wx.request({
      url: app.globalData.interface+'/post/API_1121_selectPost',
      method: 'get',
      data: {
        POST_PHONE_WHITE:'',
        OPENID: this.data.openid
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: res => {
        console.log(res.data.data);
        if (res.data.result == 'success') {
          this.setData({
            chakanxingxi:false,
            chuashuju:res.data,
          }) 
        }else{
          this.setData({
            lijigoumai:false,
            chuashuju:res.data,
          })
        }
      }
    })
  },






  


  purchasecha(){
var that = this

    console.log(111);
    wx.showModal({
      title: '温馨提示',
      content: '已有信息是否确定修改',
      success: function (res) {
        if (res.confirm) { //这里是点击了确定以后
          console.log('用户点击确定')
    
          wx.navigateTo({
            url: '../../pages/youpiaoqianzi/youpiaoqianzi?data=' + JSON.stringify(that.data.chuashuju)
          })
        } else { //这里是点击了取消以后
          console.log('用户点击取消')
       
        }
      }
    })



   
  },











  onChange(event) {
    console.log(event.detail);
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(e) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.shuju()
    this.chakangoumai() 
    this.setData({
      openid: app.globalData.openid
    });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})